|
"OnManualBuild" page’s event The FastReport core is usually responsible for report construction. It displays report’s bands in a definite order, as many times, as there are data, thus forming a finished report. Sometimes it is necessary to display a report in a non-standard form, which the FastReport core is unable to create. In this case, one can use a possibility to constructa report manually via the "OnManualBuild" event, contained in the report’s page. If the handler of this event were defined, then when forming a page the FastReport core would transfer control to it. At the same time, the report’s core automatically displays the bands located in the page, such as "Report title," "Page title," "Column title," "Report footer," "Page footer," "Column footer," and "Background." The core also handles the process of forming of new pages and columns. The task of the "OnManualBuild" event’s handler is to display data bands and their titles and footers in a definite order. That is to say, "OnManualBuild" handler’s essence is to give a command for displaying definite bands to the FastReport’s core. The core will do the rest itself: it will form a new page, as soon as there is no free space on the current one; accomplish the scripts attached to events; etc. Let us demonstrate a handler with a simple example. In the report, there are two master data bands, which are not connected to data:
The handler will display these bands in alternate order (six times each one). After six bands are created, a small gap will be inserted. procedure Page1OnManualBuild(Sender: TfrxComponent);
The following example displays two bands’ groups next to each other. procedure Page1OnManualBuild(Sender: TfrxComponent);
As you can see, in these examples we controlled typing of data-bands only. All the rest bands (for example, in our case, it was "Report title") were printed automatically. Finally, we will demonstrate, how to construct a report of the "List of clients" type (we have constructed it several times in this book) via the "OnManualBuild" event. In our example, let us connect the data-band to the data source.
Event’s script is the following: procedure Page1OnManualBuild(Sender: TfrxComponent); When starting a report, make sure that the result of the script’s work does not differ from a standard report at all. Refer to the process of getting a link to the Dataset; in our example we connected a band to the data source, that is why the DataSet := MasterData1.DataSet; line returns a link to the data source. If a band is not connected to the source, the link to the required source can be got in the following way: DataSet := Report.GetDataSet('Customers'); Of course, the source, we are interested in, must be added to the report in the "Report|Data…" dialogue |